//
//  MyHeaderCell.m
//  AnnCar_user
//
//  Created by LiBenCan on 17/10/23.
//  Copyright © 2017年 LiBenCan. All rights reserved.
//

#import "MyHeaderCell.h"

@implementation MyHeaderCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    if (!_headerImageV) {
        //头像
        _headerImageV  = [TomamaUI createImageView:CGRectMake(15*screenW_6, 15*screenW_6, 50*screenW_6, 50*screenW_6) backGroundImageV:@"My_MR"];
        [_headerImageV.layer setCornerRadius:25*screenW_6];
        _headerImageV.layer.masksToBounds = YES;
        [self.contentView addSubview:_headerImageV];
        
        //二维码
        _codeImageV = [TomamaUI createImageView:CGRectMake(SCREENW-80*screenW_6, 20*screenW_6, 40*screenW_6, 40*screenW_6) backGroundImageV:@"Code"];
        _codeImageV.userInteractionEnabled = YES;
        [self.contentView addSubview:_codeImageV];
        
        //昵称
        _nameLab = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(_headerImageV.frame)+12*screenW_6, 15*screenW_6, SCREENW/2, 25*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:16*screenW_6] textColor:[UIColor colorWithHexString:@"#666666"] text:@""];
        [self.contentView addSubview:_nameLab];
        
        //手机号
        _phoneLab = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(_headerImageV.frame)+12*screenW_6,CGRectGetMaxY(_nameLab.frame), SCREENW-90*screenW_6, 25*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:12*screenW_6] textColor:[UIColor colorWithHexString:@"#999999"] text:@""];
        [self.contentView addSubview:_phoneLab];
    }
}
//数据加载
-(void)setDataDic:(NSDictionary *)dataDic
{
    _headerImageV.image = [UIImage imageNamed:@"My_MR"];
    _nameLab.text = @"灿灿";
    _phoneLab.text = @"18326552750";
    if (_phoneLab.text.length==11) {//如果11位手机号则截取显示星号
        //字符串的截取
        NSString *string = [_phoneLab.text substringWithRange:NSMakeRange(3,_phoneLab.text.length-7)];
        _phoneLab.text = [_phoneLab.text stringByReplacingOccurrencesOfString:string withString:@"***"];
    }

}


@end
